#ifndef __POOLED_FUNCTIONS__
#define __POOLED_FUNCTIONS__

/* This file can only be included in (concurrent-)connection-pool.h */

#include <stdint.h>
#include "debug.h"
#include "protocol.h"
#include "chunk-client.h"

#define MAX_TRIES 3

#define POOLED_FUNCTION(func, ...) 											\
	int n_tries = 0;														\
	conn_record conn;														\
	extern bool show_socket_error;											\
	show_socket_error = false;												\
	PUSH_THREAD_ADDR(ip, port);												\
retry:																		\
	conn = get_connection(ip, port);										\
	if (unlikely(conn == NULL)){											\
		POP_THREAD_MAGIC();													\
		return MK_CONNECTION_ERROR(-1);										\
	}																		\
																			\
	st_netfd_t stfd = the_connection(conn);									\
	int ret = func(stfd, ##__VA_ARGS__);									\
																			\
	if (unlikely(CONNECTION_ERROR(ret))) {									\
		trash_connection(ip, port, conn);									\
		if (++n_tries < MAX_TRIES){											\
			LOG_DEBUG("retry function "#func" n_tries is %d", n_tries);		\
			show_socket_error = true;										\
			goto retry;														\
		}																	\
	} else {																\
		put_connection(ip, port, conn);										\
	}																		\
	if(unlikely(n_tries && ret<0)){											\
		LOG_INFO("retry "#func" failed finally");							\
	}																		\
	show_socket_error = true;												\
	POP_THREAD_MAGIC();														\
	return ret;																\


static inline int pooled_chunk_create(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t size, bool preallocation, bool incubation, bool checksum, bool ec_chunk)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, size=%u, preallocation=%u, incubation=%u)",
		__func__, str_ip(ip), port, volumeid, index, size, preallocation, incubation);
	POOLED_FUNCTION(chunk_create, volumeid, index, size, preallocation, incubation, checksum, ec_chunk);
}

static inline int pooled_chunk_close_fd(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	LOG_DEBUG("%s(ip=%s, port=%u, volume=%08x.%d)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_close_fd, volumeid, index);
}

static inline int pooled_chunk_list(uint32_t ip, uint16_t port, uint32_t volumeid, struct ChunkID** result)
{
	LOG_DEBUG("%s(ip=%s, port=%u, volume=%08x)", __func__, str_ip(ip), port, volumeid);
	POOLED_FUNCTION(chunk_list, volumeid, result);
}

static inline int pooled_chunk_read(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_read, volumeid, index, offset, buf, size);
}

static inline int pooled_chunk_clear_ec_record(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, int ith)
{
	LOG_INFO("%s(ip=%s, port=%u, chunk=%08x.%u, ith %d)", __func__, str_ip(ip), port, volumeid, index, ith);
	POOLED_FUNCTION(chunk_clear_ec_record, volumeid, index, ith);
}

static inline int pooled_chunk_readv(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index,
				   uint32_t offset, struct iovec *iov, uint32_t vec_num, uint32_t size)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_readv, volumeid, index, offset, iov, vec_num, size);
}

static inline int pooled_chunk_readv4(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index,
				   uint32_t offset, struct iovec *iov, uint32_t vec_num, uint32_t size, uint64_t version)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_readv4, volumeid, index, offset, iov, vec_num, size, version);
}

static inline int pooled_chunk_read2(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_read_checksum, volumeid, index, offset, buf, size);
}

static inline int pooled_chunk_flush(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	LOG_INFO("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_flush, volumeid, index);
}

static inline int pooled_chunk_write(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version, uint32_t offset, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, version=%ld)", __func__, str_ip(ip), port, volumeid, index, version);
	POOLED_FUNCTION(chunk_write, volumeid, index, version, offset, buf, size);
}

static inline int pooled_chunk_writex(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version, uint32_t offset, void* buf, uint32_t size, send_cb_t send)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, version=%ld)", __func__, str_ip(ip), port, volumeid, index, version);
	POOLED_FUNCTION(chunk_writex, volumeid, index, version, offset, buf, size, send);
}

static inline int pooled_chunk_write4(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version, uint32_t offset, void* buf, uint32_t size, uint32_t flag, time_t client_time)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, version=%ld client time %ld)", __func__, str_ip(ip), port, volumeid, index, version, client_time);
	POOLED_FUNCTION(chunk_write4, volumeid, index, version, offset, buf, size, flag, client_time);
}

static inline int pooled_chunk_writev4(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset,
									   struct iovec *iov, uint32_t vec_num, uint32_t size, uint64_t version, uint32_t flag, time_t client_time)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, version=%ld client time %ld)", __func__, str_ip(ip), port, volumeid, index, version, client_time);
	POOLED_FUNCTION(chunk_writev4, volumeid, index, offset, iov, vec_num, size, version, flag, client_time);
}

static inline int pooled_chunk_write4x(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version, uint32_t offset, void* buf, uint32_t size, uint32_t flag, time_t client_time, send_cb_t send)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, version=%ld client time %ld)", __func__, str_ip(ip), port, volumeid, index, version, client_time);
	POOLED_FUNCTION(chunk_write4x, volumeid, index, version, offset, buf, size, flag, client_time, send);
}

static inline int pooled_chunk_writev_replicate(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset,
							  struct iovec *iov, uint32_t vec_num, uint32_t size, struct CSEP* endpoints, uint32_t n)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_writev_replicate, volumeid, index, offset, iov, vec_num, size, endpoints, n);
}

static inline int pooled_chunk_update_ec_parity(uint32_t ip, uint16_t port, struct ECParityUpdateInfo *info, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, info->volumeid, info->index);
	POOLED_FUNCTION(chunk_update_ec_parity, info, buf, size);
}

static inline int pooled_chunk_write_ec_data(uint32_t ip, uint16_t port, struct ECDataWriteinfo *ec_info, void* buf, uint32_t size, char *new_replicate, char* new_success_mask)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->id.volumeid, ec_info->id.index);
	POOLED_FUNCTION(chunk_write_ec_data, ec_info, buf, size, new_replicate, new_success_mask);
}

static inline int pooled_chunk_write_data_to_parity(uint32_t ip, uint16_t port, struct ECParityUpdateInfo *ec_info, void* buf, struct ReWriteD0Record* record, bool is_d0, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->volumeid, ec_info->index);
	POOLED_FUNCTION(chunk_write_data_to_parity, ec_info, buf, record, is_d0, size);
}

static inline int pooled_chunk_write_ec_data2(uint32_t ip, uint16_t port, struct ECDataWriteinfo *ec_info, void* buf, uint32_t size, char *new_replicate, char* new_success_mask)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->id.volumeid, ec_info->id.index);
	POOLED_FUNCTION(chunk_write_ec_data2, ec_info, buf, size, new_replicate, new_success_mask);
}

static inline int pooled_chunk_write_ec_groupdata(uint32_t ip, uint16_t port, struct ECGroupDataWriteInfo *ec_g_info, void* buf, uint32_t size, uint32_t *new_replciate)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_g_info->id.volumeid, ec_g_info->id.index);
	POOLED_FUNCTION(chunk_write_ec_groupdata, ec_g_info, buf, size, new_replciate);
}

static inline int pooled_chunk_write_ec_groupdata2(uint32_t ip, uint16_t port, struct ECGroupDataWriteInfo *ec_g_info, void* buf, uint32_t size, uint32_t *new_replciate)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_g_info->id.volumeid, ec_g_info->id.index);
	POOLED_FUNCTION(chunk_write_ec_groupdata2, ec_g_info, buf, size, new_replciate);
}

static inline int pooled_chunk_write_ec(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version, uint32_t offset, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_write_ec, volumeid, index, version, offset, buf, size);
}

static inline int pooled_chunk_write_ec2(uint32_t ip, uint16_t port,
										uint32_t volumeid, uint32_t index,
										uint64_t version, uint32_t offset,
										void* buf, uint32_t size,
										wait_confirm_code_t wait_fun, void* data)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_write_ec2, volumeid, index, version, offset, buf, size, wait_fun, data);
}

static inline int pooled_chunk_write_ec_parity(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, int k, uint32_t offset, void* buf, uint32_t size, uint64_t versions[], uint8_t version_incs[])
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_write_ec_parity, volumeid, index, k, offset, buf, size, versions, version_incs);
}

static inline int pooled_chunk_check_ec_parity(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, int k, uint32_t offset, uint64_t versions[], uint8_t version_incs[])
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_check_ec_parity, volumeid, index, k, offset, versions, version_incs);
}

static inline int pooled_chunk_write_ec_on_error(uint32_t ip, uint16_t port, struct WriteECOnErrInfo *ec_info, void* buf, uint32_t size)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->id.volumeid, ec_info->id.index);
	POOLED_FUNCTION(chunk_write_ec_on_error, ec_info, buf, size);
}

static inline int pooled_chunk_writev_ec_on_error(uint32_t ip, uint16_t port, struct WriteECOnErrInfo *ec_info, struct iovec *iov, uint32_t niov, uint32_t iov_size_byte)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->id.volumeid, ec_info->id.index);
	POOLED_FUNCTION(chunk_writev_ec_on_error, ec_info, iov, niov, iov_size_byte);
}

static inline int pooled_chunk_fix_create(uint32_t ip, uint16_t port, struct ECFixCreateInfo *ec_info, struct CSEP *cseps)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, ec_info->id.volumeid, ec_info->id.index);
	POOLED_FUNCTION(chunk_fix_create, ec_info, cseps);
}

static inline int pooled_chunk_check_ec(uint32_t ip, uint16_t port, int k, int n, uint32_t volumeid, uint32_t index, uint64_t size, struct CSEP *cseps)
{
	LOG_INFO("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_check_ec, k, n, volumeid, index, size, cseps);
}

static inline int pooled_chunk_notify_new_ec_chunk(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t new_ip, uint16_t new_port, uint32_t new_index, int m)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u new index %u m %u)", __func__, str_ip(ip), port, volumeid, index, new_index, m);
	POOLED_FUNCTION(chunk_notify_new_ec_chunk, volumeid, index, new_ip, new_port, new_index, m);
}

static inline int pooled_chunk_write_replicate(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset, void* buf, uint32_t size, struct CSEP* endpoints, uint32_t n)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_write_replicate, volumeid, index, offset, buf, size, endpoints, n);
}

static inline int pooled_chunk_write_replicate3(uint32_t ip , uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset, void* buf, uint32_t size, struct CSEP* endpoints, uint32_t n)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_write_replicate3, volumeid, index, offset, buf, size, endpoints, n);
}

static inline int pooled_chunk_writev_replicate2(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset,
							  struct iovec *iov, uint32_t vec_num, uint32_t size, struct CSEP* endpoints, uint32_t n,
							  uint64_t *ret_version, char *ret_mask)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_writev_replicate2, volumeid, index, offset, iov, vec_num, size, endpoints, n, ret_version, ret_mask);
}

static inline int pooled_chunk_writev_replicate4(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset,
							  struct iovec *iov, uint32_t vec_num, uint32_t size, struct CSEP* endpoints, uint32_t n,
							  uint64_t data_version, uint32_t flag, uint64_t *ret_version, char *ret_mask)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_writev_replicate4, volumeid, index, offset, iov, vec_num, size, endpoints, n, data_version, flag, ret_mask, ret_version);
}

static inline int pooled_chunk_write_replicate2(uint32_t ip , uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset, void* buf, uint32_t size, struct CSEP* endpoints, uint32_t n,
																				uint64_t *ret_version, char *ret_mask)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_write_replicate2, volumeid, index, offset, buf, size, endpoints, n, ret_version, ret_mask);
}

static inline int pooled_chunk_create_write_replicate(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t offset,
		void* buf, uint32_t size, struct CSEP* endpoints, uint32_t n, bool preallocation, bool incubation)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_create_write_replicate, volumeid, index, offset, buf, size, endpoints, n, preallocation, incubation);
}

static inline int pooled_chunk_get_version(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t *version)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_get_version, volumeid, index, version);
}

static inline int pooled_chunk_get_ec_version(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, int nb_to_get, uint64_t *versions)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_get_ec_version, volumeid, index, nb_to_get, versions);
}

static inline int pooled_chunk_delete(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	// LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	LOG_INFO("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_delete, volumeid, index);
}

static inline int pooled_chunk_undelete(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_undelete, volumeid, index);
}

static inline int pooled_chunk_checksum_sha1(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, void* buf)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_checksum_sha1, volumeid, index, buf);
}

static inline int pooled_chunk_clone(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_clone, volumeid, index);
}

static inline int pooled_chunk_breed(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t since_version, uint32_t to_ip, uint16_t to_port)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u, since_version=%llu, to_ip=%s, to_port=%u)",
			__func__, str_ip(ip), port, volumeid, index, since_version, str_ip(to_ip), to_port);
	POOLED_FUNCTION(chunk_breed, volumeid, index, since_version, to_ip, to_port);
}

static inline int pooled_chunk_sync_data(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t since_version, uint32_t from_ip, uint16_t from_port)
{
	LOG_DEBUG("%s(ip=%x, port=%u, chunk=%08x.%u, since_version=%llu, from_ip=%x, from_port=%u)",
				__func__, ip, port, volumeid, index, since_version, from_ip, from_port);
	POOLED_FUNCTION(chunk_sync_data, volumeid, index, since_version, from_ip, from_port);
}

static inline int pooled_chunk_get_info(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, void *info, uint64_t *chunk_data_size)
{
	LOG_DEBUG("%s (ip=%x, port=%u, chunk=%08x.%u)", __func__, ip, port, volumeid, index);
	POOLED_FUNCTION(chunk_get_info, volumeid, index, info, chunk_data_size);
}

static inline int pooled_chunk_suspend_write(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, bool to_suspend)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_suspend_write, volumeid, index, to_suspend);
}

static inline int pooled_chunk_notify_new_replica(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t replica_ip, uint16_t replica_port)
{
	LOG_INFO("%s(ip=%s, port=%u, chunk=%08x.%u new one %s:%u)", __func__, str_ip(ip), port, volumeid, index, str_ip(replica_ip), replica_port);
	POOLED_FUNCTION(chunk_notify_new_replica, volumeid, index, replica_ip, replica_port);
}

static inline int pooled_chunk_notify_incubation_done(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint64_t version)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_notify_incubation_done, volumeid, index, version);
}

static inline int pooled_chunk_server_terminate(uint32_t ip, uint16_t port, int code)
{
	LOG_DEBUG("%s(ip=%s, port=%u, code=%d)", __func__, str_ip(ip), port, code);
	POOLED_FUNCTION(chunk_server_terminate, code);
}

static inline int pooled_chunk_server_ping(uint32_t ip, uint16_t port)
{
	LOG_DEBUG(__func__);
	POOLED_FUNCTION(chunk_server_ping);
}

static inline int pooled_chunk_flush_ec_journal(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index)
{
	LOG_DEBUG("%s(ip=%s, port=%u, chunk=%08x.%u)", __func__, str_ip(ip), port, volumeid, index);
	POOLED_FUNCTION(chunk_flush_ec_journal, volumeid, index);
}

static inline int
pooled_chunk_server_restart(uint32_t ip, uint16_t port)
{
	LOG_DEBUG("[%s:%d] ip: %s, port: %d", __func__, __LINE__, str_ip(ip), port);
	POOLED_FUNCTION(chunk_server_restart);
	return 0;
}

static inline int pooled_chunk_rename(uint32_t ip, uint16_t port, uint32_t volumeid, uint32_t index, uint32_t volumeid1, uint32_t index1)
{
	LOG_DEBUG(__func__);
	POOLED_FUNCTION(chunk_rename, volumeid, index, volumeid1, index1);
}

static inline int pooled_chunk_flushjournal(uint32_t ip, uint16_t port, bool delete_after_flush)
{
	POOLED_FUNCTION(chunk_flushjournal, delete_after_flush);
}

static inline int __close_connection(st_netfd_t stfd) { return MK_CONNECTION_ERROR(-1); }
static inline int pooled_close_connection(uint32_t ip, uint16_t port)
{
	LOG_DEBUG("%s(ip=%s, port=%u)", __func__, str_ip(ip), port);
	POOLED_FUNCTION(__close_connection);
}

#undef POOLED_FUNCTION

#endif
